package com.yoga.admin.api.web;

import com.yoga.common.appexception.AppErrorCodeEnum;
import com.yoga.common.appexception.AppException;
import com.yoga.common.appexception.YogaResult;
import com.yoga.manager.upyun.UploadChannelEnum;
import com.yoga.manager.upyun.UploadUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by chenjin on 2020/2/23.
 */

@RestController
@RequestMapping("${basePath}")
public class AdminUploadController {

    @PostMapping("/upload-image")
    public YogaResult uploadImage(UploadChannelEnum uploadChannel, @RequestParam("file") MultipartFile file) {
        return new YogaResult(UploadUtils.upload(uploadChannel, file));
    }


}
